package com.beimihu.leetcode.滑动窗口;


import org.apache.commons.math3.analysis.function.Max;

//https://leetcode.cn/problems/minimum-size-subarray-sum/description/?envType=study-plan-v2&envId=top-interview-150 滑动窗口
public class MinSubArrayLen209 {
    public int minSubArrayLen(int target, int[] nums) {
        // target = 7, nums = [2,3,1,2,4,3]
        int start  = 0, end = 0;
        int len = nums.length;
        int sum = 0;
        int res = Integer.MAX_VALUE;
        while(end < len){
            sum = sum + nums[end];
            if(sum >= target){
                res = Math.min(res,end - start + 1);
                sum = sum - nums[start];
                start++;
            }
        }
        return 0;


    }
}
